home *** CD-ROM | disk | FTP | other *** search
- #!/usr/bin/perl
-
- #__________________________________________________________
- #
- # File: wrap
- # By: Matt Ho
- # Date: 7/23/95
- # Purpose: Wrapper to dynamically create HTML documents
- # that contain a easy to read directory content.
- #__________________________________________________________
-
-
- require "flush.pl";
-
- #__________________________________________________________
- #
- # SGI Patch 2222 disables the 'download' feature for
- # security reasons. This functionality will removed
- # entirely in the next release.
- #
- # The supported way for a user to download a file is
- # to use the browser 'Save Link' feature.
- #
- # If you need to restore this functionality, and you are
- # behind a firewall, and trust all others behind that
- # firewall, then change the line below to:
- # $HANDLER_DISABLED = 0 ;
- #__________________________________________________________
-
- $HANDLER_DISABLED = 1 ;
-
- #__________________________________________________________
- #
- # Set some environment variables, we'll need through the
- # script and do some initial error checking.
- #__________________________________________________________
-
- $ROOT = "/var/www/htdocs" ; # Root directory
- $PATH = $ENV{'PATH_INFO'} ;
- $wrap = "/cgi-bin/wrap" ; # Script alias for this CGI
- $ls = "/sbin/ls -a1" ;
- $outboxcgi = "/var/www/cgi-bin/outbox-cgi" ;
- #__________________________________________________________
- #
- # Read the form data in. PATH_INFO may be passed here
- # if this was called from a SSI. We're going to make
- # one final tweak and read from the arg list as well
- # for SSI's.
- #__________________________________________________________
-
- if( $ENV{'REQUEST_METHOD'} eq "GET" )
- {
- $buffer=$ENV{'QUERY_STRING'} ;
- }
- else
- {
- read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}) ;
- }
-
- @pairs = split(/&/, $buffer) ;
- foreach (@pairs)
- {
- tr/+/ / ;
- ($name,$value) = split(/=/) ;
- $value =~ s/%(..)/pack("c",hex($1))/ge ;
- $name =~ s/%(..)/pack("c",hex($1))/ge ;
-
- $FORM{$name} = $value ;
- }
-
- #_________________________________
- #
- # Some basic checks to take
- # care of
- #_________________________________
-
- if( $ARGV[0] )
- {
- $PATH = $ARGV[0] ;
- $arg = 1 ;
- }
-
- # trim off undesirable meta chars.
- $PATH =~ s/[|;]//g ;
-
- chop $PATH if substr($PATH, -1) eq "/" ;
- @_ = split('/', $PATH) ;
- $pathRoot = $_[$#_] ;
- $doc = $ROOT.$PATH ;
-
- &ErrBadPath if ! defined $PATH || $PATH eq "" ; # check for empty path
- &ErrBadPath unless &ValidPath ; # Check for server spoofing
- &ErrBadPath unless -e $doc ; # Check to see it exists
- &ErrBadPath if -f $doc ; # Don't allow download of file via wrap
-
- #__________________________________________________________
- #
- # If we get to this point, we can be reasonably certain
- # that this is a valid shared directory. We want to
- # show it using the appropriate method. The following
- # section is the leading data. ShowContents will supply
- # the rest of the data.
- #
- # We do, however, need to account for the user putting
- # an index.html file in the directory. We'll handle
- # that as follows. If the file exists, it is assumed to
- # be in the right. We will append out data at the end,
- # using the index.html's head section. Otherwise, we
- # will use ours.
- #__________________________________________________________
-
- if( $arg == 1 )
- {
- # This is intentionally left blank
- }
- elsif( -r "$doc/index.html" )
- {
- print "Content-type: text/html\n\n" ;
-
- open(INDEX, "$doc/index.html") ;
- while( <INDEX> )
- {
- s/<!--#exec/<!-- exec/g ;
- last if /<\/[bB][oO][dD][yY]>/ ;
- last if /<\/[hH][tT][mM][lL]>/ ;
- print ;
- if ( /<BODY/ || /<body/)
- {
- if ( ! />/ )
- {
- while( <INDEX> )
- {
- print ;
- last if ( />/ ) ;
- }
- }
- &flush(STDOUT) ;
- system '/var/www/cgi-bin/outbox-cgi', $PATH;
- }
- }
- close(INDEX) ;
- }
- else
- {
- print <<ENDOFTEXT ;
- Content-type: text/html
-
- <head>
- <title>
- $pathRoot
- </title>
- </head>
-
- <body bgcolor="c1c1c1" text="000000" link="0000ee" vlink="0000ee"
- alink="0000ff" background="/outbox/images/background.gif">
- ENDOFTEXT
-
- &flush(STDOUT) ;
- system '/var/www/cgi-bin/outbox-cgi', $PATH ;
- &flush(STDOUT) ;
- print <<ENDOFTEXT ;
- <B>$pathRoot:</B>
- ENDOFTEXT
- }
-
- #
- # RFE - people getting confused with all these choices.
- #
- # &ShowSelection ;
-
- &ShowContents ;
-
- print "\n</body>\n</html>\n\n" unless $arg == 1 ;
-
-
-
- #__________________________________________________________
- #__________________________________________________________
- #__________________________________________________________
-
-
-
- sub ErrBadPath
- {
- print <<ENDOFTEXT ;
- Content-type: text/html
-
- <HTML>
- <HEAD><TITLE>OutBox: File Not Found</TITLE></HEAD>
- <BODY><H2>OutBox: File Not Found</H2>
- The requested file "$PATH" was not found on this OutBox page.
- <P>
- ENDOFTEXT
-
- if( defined $ENV{'HTTP_REFERER'} )
- {
- $referer = $ENV{'HTTP_REFERER'} ;
- print <<ENDOFTEXT ;
- <a href="$referer"><IMG SRC="/outbox/images/go-back.gif" BORDER=0 ALT="Back"></A>
- ENDOFTEXT
- }
-
- print <<ENDOFTEXT ;
- </BODY>
- </HTML>
- ENDOFTEXT
-
-
- exit ;
- }
-
- #__________________________________________________________
-
- sub ValidPath
- {
- return 1 unless /\.\./ ;
-
- return '' if /^\.\./ ;
- return '' if /\/\.\.\// ;
- return '' if /\.\.$/ ;
-
- return 1 ;
- }
-
- #__________________________________________________________
-
- sub IsHiddenFile
- {
- local($fname) = $_[$#_];
-
- return 1 if $fname eq "index\.html" ;
- return 1 if $fname eq "index\.html\.O" ;
- return 1 if $fname eq "index\.html\.N" ;
- return 1 if $fname eq "index\.shtml" ;
- return 1 if $fname eq "index\.shtml\.O" ;
- return 1 if $fname eq "index\.shtml\.N" ;
- return 1 if $fname eq "default\.gif" ;
- return 1 if ( $fname =~ /^\./ ) ;
- return 1 if ( $fname =~ /\.bak$/ ) ;
- return 1 if ( $fname =~ /\.sav$/ ) ;
- return 1 if ( $fname =~ /~$/ ) ;
-
- return '' ;
- }
-
- #__________________________________________________________
-
- sub ShowSelection
- {
- local(@select) ;
-
- $FORM{'format'} = "default" unless defined $FORM{'format'} ;
- $select{$FORM{'format'}} = "checked" ;
-
- print <<ENDOFTEXT ;
-
- <center>
- <table cellpadding=2 cellspacing=0 border=0>
- <form action="$wrap$PATH" method=get>
- <tr>
- <td><b>Viewing format:</b>
- <input type="radio"
- name="format"
- value="default"
- $select{'default'}> Default
- <input type="radio"
- name="format"
- value="long"
- $select{'long'}> Long
- <input type="radio"
- name="format"
- value="short"
- $select{'short'}> Short </th>
- <td align=center>
- <input type="submit" value="Apply"></td>
- </tr>
- </form>
- </table>
- </center>
-
- ENDOFTEXT
- }
-
-
- #__________________________________________________________
-
- sub ShowContents
- {
- local($format) = $FORM{'format'} ;
-
- #_________________________________
- #
- # Get the directory and do
- # some sorting (directories)
- # come first, then files.
- #_________________________________
-
- open (FIND,"$ls $ROOT$PATH |") ;
- while( <FIND> )
- {
- chop ;
- next if $_ eq "\." ;
- next if ( $_ eq "\.\." && "/$pathRoot" eq $PATH ) ;
- next if ( /^\./ && $_ ne "\.\." ) ;
- next if $_ eq "RCS" ;
- next if ( ! -r "$ROOT$PATH/$_" ) ;
- next if ( -d "$ROOT$PATH/$_" && ! -x "$ROOT$PATH/$_" ) ;
- push(@d, $_), next if -d "$ROOT$PATH/$_" ;
- push(@f, $_) ;
- }
-
- #_________________________________
- #
- # Select method of display
- #_________________________________
-
- &ListFolders(@d) ;
-
- $format = "default" if ! defined $format ;
-
- if( $format eq "long" )
- {
- &ListLong(@f) ;
- }
- elsif( $format eq "short" )
- {
- &ListShort(@f) ;
- }
- else # default format
- {
- &ListDefault(@f) ;
- }
- }
-
- #__________________________________________________________
-
- sub ListFolders
- {
- local($size) = $#_ + 1 ;
- local($i) ;
- local($j) ;
- local($index) ;
- local($format) ;
- local($cols) = 3 ;
- local($rows) = $size / $cols ;
- local($left) = $size % $cols ;
- local($label) ;
- local($image) ;
-
- return if $size == 0 ;
-
- #_________________________________
-
- $format = "?format=$FORM{'format'}" if defined $FORM{'format'} ;
-
- #_________________________________
-
- $rows = sprintf("%.0d", $rows) ;
- $rows++ if $left > 0 ;
-
- print <<ENDOFTEXT ;
- </center>
- <table cellpadding=0 cellspacing=0 width="100%" border=0>
- ENDOFTEXT
- LOOP:
- for( $i = 0 ; $i < $rows ; $i++ )
- {
- print "<tr>\n" ;
- for( $j = 0 ; $j < $cols ; $j++ )
- {
- $index = $i + $j * $rows ;
-
- if( $index >= $size )
- {
- print "<td></td>\n" ;
- next ;
- }
- if ( $_[$index] eq ".." )
- {
- $label = "" ;
- $image = "/outbox/images/go-back.gif" ;
- }
- else
- {
- $label = "$_[$index]" ;
- $image = "/outbox/images/file_folder.gif" ;
- }
-
- print <<ENDOFTEXT ;
- <td>
- <a href="$wrap$PATH/$_[$index]/$format"><img src="$image" align=middle border=0></a>
- ENDOFTEXT
- if ( $label ne "" )
- {
- print " <a href=\"$wrap$PATH/$_[$index]/$format\">$label</a>" ;
- }
- print "</td>"
- }
- print "</tr>\n" ;
- }
-
- print <<ENDOFTEXT ;
- </table>
- ENDOFTEXT
- }
-
- #__________________________________________________________
-
- sub ListDefault
- {
- local(@notes) ;
- local($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,@other) ;
- local($USERPATH) = $PATH ;
- local($first) = 1 ;
- local($image) ;
- local($url) ;
-
- $dltext = `/usr/bin/gettxt uxoutbox:22 "(download)"` ;
-
- return if ( $#_ == -1 ) ;
-
- substr($USERPATH, 0, 1) = "/~" ;
-
- print <<ENDOFTEXT ;
-
- </center>
- <div align=left>
- ENDOFTEXT
-
- foreach (@_)
- {
- next if &IsHiddenFile($_) ;
-
- if ( /\.notes$/ )
- {
- $base = $_ ;
- $base =~ s/\.notes$// ;
- next if -r "$doc/$base" ;
- }
-
- if ($first == 1)
- {
- $first = 0 ;
- print "<HR ALIGN=LEFT WIDTH=\"80%\">\n" if ($#d >= 0) ;
- print "<table cellpadding=0 cellspacing=1 border=0>" ;
- }
-
- #_________________________________
- #
- # Calculate the size of this
- # file
- #_________________________________
-
- ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,@other) =
- stat("$doc/$_") ;
-
- if( $size == 1 )
- {
- $size = "<b>$size</b> byte" ;
- }
- elsif( $size >= 1024 )
- {
- $size = $size / 1024 ;
- $size = sprintf("%.0d", $size) ;
- $size = "<b>$size</b> KB" ;
- }
- else
- {
- $size = "<b>$size</b> bytes" ;
- }
-
- #_________________________________
- #
- # Add notes if applicable
- #_________________________________
-
- if( -r "$doc/$_.notes" )
- {
- open(DATA, "$doc/$_.notes") ;
- @notes = <DATA> ;
- close(DATA) ;
- }
-
- #_________________________________
- #
- # figure out which image to use
- #_________________________________
-
- # defaults
-
- $image = "" ;
- $url = "" ;
-
- # audio
-
- $image = "file_audio.gif" if ( /\.[aA][uU]$/ ) ;
- $image = "file_audio.gif" if ( /\.[aA][iI][fF]$/ ) ;
- $image = "file_audio.gif" if ( /\.aif[cf]$/ ) ;
- $image = "file_audio.gif" if ( /\.[sS][nN][dD]$/ ) ;
- $image = "file_audio.gif" if ( /\.[wW][aA][vV]$/ ) ;
- $image = "file_audio.gif" if ( /\.[rR][aA]$/ ) ;
- $image = "file_audio.gif" if ( /\.[rR][aA][mM]$/ ) ;
- $image = "file_audio.gif" if ( /\.[aA][bB][sS]$/ ) ;
- $image = "file_audio.gif" if ( /\.[mM][pP][2a]$/ ) ;
- $image = "file_audio.gif" if ( /\.[mM][pP][2a][2a]$/ ) ;
- $image = "file_audio.gif" if ( /\.[mM][pP][eE][gG][aA]$/ ) ;
-
- # image
-
- $image = "file_image.gif" if ( /\.[gG][iI][fF]$/ ) ;
- $image = "file_image.gif" if ( /\.[iI][eE][fF]$/ ) ;
- $image = "file_image.gif" if ( /\.tiff$/ ) ;
- $image = "file_image.gif" if ( /\.[tT][iI][fF]$/ ) ;
- $image = "file_image.gif" if ( /\.[jJ][pP][gG]$/ ) ;
- $image = "file_image.gif" if ( /\.jpeg$/ ) ;
- $image = "file_image.gif" if ( /\.[jJ][pP][eE]$/ ) ;
- $image = "file_image.gif" if ( /\.rgb$/ ) ;
- $image = "file_image.gif" if ( /\.ras$/ ) ;
- $image = "file_image.gif" if ( /\.pcd$/ ) ;
- $image = "file_image.gif" if ( /\.p[nbgp]m$/ ) ;
- $image = "file_image.gif" if ( /\.x[bp]m$/ ) ;
- $image = "file_image.gif" if ( /\.xwd$/ ) ;
- $image = "file_image.gif" if ( /\.icon$/ ) ;
- $image = "file_image.gif" if ( /\.fti$/ ) ;
-
- # video
-
- $image = "file_movie.gif" if ( /\.movie$/ ) ;
- $image = "file_movie.gif" if ( /\.[mM][oO][vV]$/ ) ;
- $image = "file_movie.gif" if ( /\.moov$/ ) ;
- $image = "file_movie.gif" if ( /\.[mM][vV]$/ ) ;
- $image = "file_movie.gif" if ( /\.[qQ][tT]$/ ) ;
- $image = "file_movie.gif" if ( /\.[aA][vV][iI]$/ ) ;
- $image = "file_movie.gif" if ( /\.[mM][pP][eEgGsSvV]$/ ) ;
- $image = "file_movie.gif" if ( /\.[mM][pP][2sSvV][2sSvV]$/ ) ;
- $image = "file_movie.gif" if ( /\.[mM][pP][eE][gG]$/ ) ;
- $image = "file_movie.gif" if ( /\.[mM][pP][eE][gG][vV]$/ ) ;
-
- # html
-
- $image = "file_html.gif" if ( /\.[hH][tT][mM][lL]$/ ) ;
- $image = "file_html.gif" if ( /\.[hH][tT][mM]$/ ) ;
- $image = "file_html.gif" if ( /\.[sS][hH][tT][mM][lL]$/ ) ;
-
- # PostScript
-
- $image = "file_ps.gif" if ( /\.[pP][sS]$/ ) ;
- $image = "file_ps.gif" if ( /\.[eE][pP][sS]$/ ) ;
-
- # text
-
- $image = "file_text.gif" if ( /\.[tT][xX][tT]$/ ) ;
- $image = "file_text.gif" if ( /\.[rR][tT][xX]$/ ) ;
- $image = "file_text.gif" if ( /\.[rR][tT][fF]$/ ) ;
- $image = "file_text.gif" if ( /\.doc$/ ) ;
- $image = "file_text.gif" if ( /\.fm$/ ) ;
- $image = "file_text.gif" if ( /\.mif$/ ) ;
-
- # development
-
- $image = "file_makefile.gif" if ( /[Mm]akefile.*$/ ) ;
- $image = "file_core.gif" if ( $_ eq "core" ) ;
- $image = "file_h.gif" if ( /\.[hH]$/ ) ;
- $image = "file_c.gif" if ( /\.c$/ ) ;
- $image = "file_cxx.gif" if ( /\.[cC[xX][xX]$/ ) ;
- $image = "file_cxx.gif" if ( /\.[cC]\+\+$/ ) ;
- $image = "file_cxx.gif" if ( /\.C$/ ) ;
- $image = "file_cxx.gif" if ( /\.[cC][cC]$/ ) ;
- $image = "file_obj.gif" if ( /\.[oO]$/ ) ;
- $image = "file_java.gif" if ( /\.java$/ ) ;
- $image = "file_javaclass.gif" if ( /\.class$/ ) ;
-
- # showcase
-
- $image = "file_showcase.gif" if ( /\.sc$/ ) ;
- $image = "file_showcase.gif" if ( /\.slides$/ ) ;
- $image = "file_showcase.gif" if ( /\.sho$/ ) ;
- $image = "file_showcase.gif" if ( /\.show$/ ) ;
-
- # command scripts
-
- $image = "file_shell.gif" if ( /\.pl$/ ) ;
- $image = "file_shell.gif" if ( /\.sh$/ ) ;
- $image = "file_shell.gif" if ( /\.csh$/ ) ;
-
- # DOS/Windows
-
- $image = "file_ms_exe.gif" if ( /\.[bB][aA][tT]$/ ) ;
- $image = "file_ms_exe.gif" if ( /\.[eE][xX][eE]$/ ) ;
- $image = "file_ms_exe.gif" if ( /\.[cC][oO][mM]$/ ) ;
- $image = "file_ms_pp.gif" if ( /\.[pP][pP][tT]$/ ) ;
- $image = "file_ms_access.gif" if ( /\.[aA][dD][bB]$/ ) ;
- if ( /\.[xX][lL].$/ )
- {
- open(FILE, "$ROOT/$PATH/$_") ;
- read(FILE,$buf,3);
- $image = "file_ms_excel.gif"
- if (substr($buf,0,2) eq "\xd0\xcf" ||
- substr($buf,0,1) eq "\x09" &&
- substr($buf,2,1) eq "\x06") ;
- close(FILE);
- }
- if ( /\.[dD][oO][cCtT]$/ )
- {
- open(FILE, "$ROOT/$PATH/$_") ;
- read(FILE,$buf,2);
- $image = "file_ms_word.gif"
- if ($buf eq "\xfe\x37" ||
- $buf eq "\xdb\xa5" ||
- $buf eq "\xd0\xcf") ;
- close(FILE);
- }
- if ( /\.[fF][mM]$/ )
- {
- open(FILE, "$ROOT/$PATH/$_") ;
- read(FILE,$buf,4);
- $image = "file_claris_fm.gif"
- if ($buf eq "\x00\x01\x00\x00" ||
- $buf eq "\x00\x02\x00\x00") ;
- close(FILE);
- }
-
-
- # other
-
- $image = "file_iv.gif" if ( /\.iv$/ ) ;
- $image = "file_iv.gif" if ( /\.ano$/ ) ;
- $image = "file_tar.gif" if ( /\.[tT][aA][rR]$/ ) ;
- $image = "file_compress.gif" if ( /\.[gG][zZ]$/ ) ;
- $image = "file_compress.gif" if ( /\.[tT][gG][zZ]$/ ) ;
- $image = "file_compress.gif" if ( /\.Z$/ ) ;
- $image = "file_vrml.gif" if ( /\.vrml$/ ) ;
- $image = "file_vrml.gif" if ( /\.vrml\.gz$/ ) ;
- $image = "file_vrml.gif" if ( /\.wrl$/ ) ;
- $image = "file_vrml.gif" if ( /\.wrl\.gz$/ ) ;
- $image = "file_midi.gif" if ( /\.[mM][iI][dD]$/ ) ;
- $image = "file_midi.gif" if ( /\.[mM][iI[dD][iI]$/ ) ;
- $image = "file_pdf.gif" if ( /\.[pP][dD][fF]$/ ) ;
- $image = "file_director.gif" if ( /\.[dD][cCxXiI][rR]$/ ) ;
-
- # generic ms-windows application data
- # (i.e. has suffix, no types above match)
- if ( $image eq "" && /..*\...*$/ )
- {
- open(FILE, "$ROOT/$PATH/$_") ;
- read(FILE,$buf,16);
- $image = "file_ms_generic.gif"
- if ($buf eq "\xd0\xcf\x11\xe0\xa1\xb1\x1a\xe1\x00\x00\x00\x00\x00\x00\x00\x00" ||
- $buf eq "\x09\x04\x06\x00\x00\x00\x10\x00\xf6\x05\x5c\x00\x20\x00\x03\x2e") ;
- close(FILE);
- }
-
- # types without suffix
-
- if ( $image eq "" )
- {
- open(FILE, "$ROOT/$PATH/$_") ;
- if ( $string = <FILE> )
- {
- # WebJumper
- if ( $string =~ /^\#SGIWebJumpsite/ ||
- $string =~ /^\#NetscapeURL/ )
- {
- $image = "file_webjumper.gif";
- while ( $string = <FILE> )
- {
- $string =~ s/\n$// ;
-
- # look for ://, and other url types
- if ( $string =~ /:\/\// ||
- $string =~ /^mailto:/ ||
- $string =~ /^file:/ ||
- $string =~ /^about:/ ||
- $string =~ /^news:/ ||
- $string =~ /^mailbox:/ )
- {
- # don't view it, go to it.
- $url = $string ;
- last ;
- }
- else
- {
- # use as a note, if no .notes file
- @notes = ( $string )
- if ( @notes == 0 &&
- $string ne "URL Pasted into Desktop" ) ;
- }
- }
- }
-
- # command script
- $image = "file_shell.gif" if ( $string =~ /^\#!\/bin\/.*sh/ ) ;
- $image = "file_shell.gif" if ( $string =~ /^\#!\/usr\/s*bin\/perl/ ) ;
- }
- close(FILE) ;
- }
-
- # generic executable
-
- if ( $image eq "" )
- {
- $image = "file_exec.gif" if ( -x "$ROOT/$PATH/$_" ) ;
- }
-
- # default to generic data file icon
-
- $image = "file_data.gif" if ( $image eq "" ) ;
-
- # default to view data
-
- $url = "$USERPATH/$_" if ( $url eq "" ) ;
-
- #_________________________________
- #
- # Diplay the data in table form
- #_________________________________
-
- print <<ENDOFTEXT ;
- <tr>
- <td>
- <a href="$url"><img src="/outbox/images/$image" align=middle border=0></a>
- </td>
- <td>
- <a href="$url">$_</a>
- </td>
- <td>
- $size
- </td>
- <td align=left>
- ENDOFTEXT
- if ( $HANDLER_DISABLED == 0 ) {
- print "<a href=\"/cgi-bin/handler$PATH/$_?data=Download\">$dltext</a>\n" ;
- }
- print " </td>\n" ;
-
- #_________________________________
- #
- # If there is a .notes file,
- # show the message within the
- # HTML doc.
- #_________________________________
-
- if ( @notes > 0 )
- {
- print "<td>" ;
- foreach (@notes)
- {
- print ;
- }
- print "</td>\n" ;
- @notes = () ;
- }
- print "</tr>\n" ;
- }
- print "</table></center>\n" if $first == 0 ;
- }
-
- #__________________________________________________________
-
- sub ListShort
- {
- local($size) = $#_ + 1 ;
- local($i) ;
- local($j) ;
- local($index) ;
- local($cols) = 3 ;
- local($rows) = $size / $cols ;
- local($left) = $size % $cols ;
-
- return if $size == 0 ;
-
- $rows = sprintf("%.0d", $rows) ;
- $rows++ if $left > 0 ;
-
- print <<ENDOFTEXT ;
-
- </center>
- <h3>Shared Files:</h3>
-
- <table cellpadding=5 cellspacing=3 border width="100%"><tr><td>
- <table cellpadding=3 width="100%">
- ENDOFTEXT
- LOOP:
- for( $i = 0 ; $i < $rows ; $i++ )
- {
- print "<tr>\n" ;
- for( $j = 0 ; $j < $cols ; $j++ )
- {
- $index = $i + $j * $rows ;
- if( $index >= $size )
- {
- print "<td></td>\n" ;
- next ;
- }
- print <<ENDOFTEXT ;
- <td>
- <a href="$PATH/$_[$index]">
- <img src="/outbox/images/file_data.gif" align=middle border=0>
- $_[$index]
- </a>
- </td>
- ENDOFTEXT
- }
- print "</tr>\n" ;
- }
-
- print <<ENDOFTEXT ;
- </table>
- </td></tr></table>
- ENDOFTEXT
- }
-
- #__________________________________________________________
-
- sub ListLong
- {
- local($unit) ;
- local(@other) ;
- local($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size) ;
- local($atime, $mtime, $ctime) ;
- local($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) ;
-
- return if $#_ == -1 ;
-
- print <<ENDOFTEXT ;
-
- <h3>Shared Files:</h3>
- <table cellpadding=5 cellspacing=3 border width="100%">
- <tr><td>
- <pre>
-
- ENDOFTEXT
-
- foreach (@_)
- {
- #_________________________________
- #
- # stat document and get the
- # pertinent info on it. Also
- # get a unit for the size, ie
- # bytes or Kb, etc
- #_________________________________
-
- ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
- $atime, $mtime, $ctime, @other) =
- stat("$doc/$_") ;
-
- if( $size == 1 )
- {
- $unit = "byte" ;
- }
- elsif( $size >= 1024 )
- {
- $size = $size / 1024 ;
- $size = sprintf("%.0d", $size) ;
- $unit = "KB" ;
- }
- else
- {
- $unit = "bytes" ;
- }
-
- #_________________________________
- #
- # Get last mod time
- #_________________________________
-
- ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,@other) =
- localtime($ctime) ;
- $theDay = (Sun,Mon,Tue,Wed,Thu,Fri,Sat)[$wday] ;
- $theMonth = (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec)[$mon] ;
- $date = sprintf("$theDay $theMonth $mday %02d:%02d:%02d 19$year",
- $hour, $min, $sec) ;
-
- #_________________________________
-
- local($filler) = " " x (25 - length($_)) ;
- $filler = 0 if $filler < 0 ;
- print sprintf("<a href=\"$PATH/$_\"><img src=\"/outbox/images/file_data.gif\" align=middle border=0> %.25s</a>%s %6d %-5.5s %s\n", $_, $filler, $size, $unit, $date) ;
- }
-
- print <<ENDOFTEXT ;
- </pre>
- </td></tr>
- </table>
- ENDOFTEXT
- }
-
-